from selenium.webdriver.common.by import By
from xkw_UI_auto.TestDatas.loginDatas.home_datas import HomeData as HD


class HomeLocator:

    # 页面提示信息
    center_Msg = (By.CSS_SELECTOR, '.el-message__content')

    # 文件名/文件夹名称
    get_file = (By.XPATH, '//span[@class="span-title" and text()="{}"]'.format(HD.fileName))

    # 文件上传按钮
    upload_btn = (By.CSS_SELECTOR, '#bk-upload')

    # 上传文件界面文件名输入框
    input_file_name = (By.XPATH, '//input[@placeholder="请输入资源标题"]')

    # 上传文件界面确定按钮
    submit_file = (By.XPATH, '//input[@placeholder="请输入资源标题"]/ancestor::div['
                             '@class="el-dialog__body"]/following-sibling::div//button[contains(text(),"确定")]')

    # 用户头像
    user_img = (By.CSS_SELECTOR, '.user-info.fl img')
    user_get_id = (By.CSS_SELECTOR, '.user-info.fl span.el-avatar')
    # 用户信息 帮助中心 #el-popover-5710 span.bk-head-options a
    # 用户信息 账号设置 #el-popover-5710 span.bk-head-options span
    # 用户名按钮
    bk_username_btn = (By.CSS_SELECTOR, '[title="账号设置"]')

    # 客户端下载按钮
    client_download_btn = (By.CSS_SELECTOR, '[href="#/download"]')

    # 退出按钮
    logout_button = (By.XPATH, "//span[contains(text(),'退出')]")

    # 意见反馈按钮
    feed_back = (By.XPATH, "//i[contains(@class,'iconfankui')]")

    # 意见反馈描述信息
    input_desc = (By.XPATH, '//textarea[@placeholder="请输入20字以上的问题描述..."]')
    # 意见反馈界面上传图片按钮
    feed_back_pic = (By.CSS_SELECTOR, '#bk-feed-image')
    # 意见反馈提交按钮
    submit_btn = (By.XPATH, "//button[contains(text(),'提交')]")

    # 导航条找资源
    nav_source = (By.CSS_SELECTOR, '.find-more')

    # 新建文件夹
    new_folder = (By.XPATH, "//button[contains(text(),'新建文件夹')]")

    # 新建文件夹、修改文件输入框、提交定位
    reName_fileName = (By.CSS_SELECTOR, '.el-input__inner')  # 输入框
    reName_fileName_submit = (By.CSS_SELECTOR, '.el-input-group__append a.bk-item-ok')  # 提交按钮

    # 更多操作按钮 ...
    drop_btn = (By.XPATH, "//span[text()='{}']/ancestor::div["
                          "@class='list-item-content']/following-sibling::div//span[contains(@class,"
                          "'el-dropdown-link')]".format(HD.fileName))

    # 删除文件按钮
    del_btn = (By.XPATH, "//span[text()='{}']/ancestor::div["
                         "@class='list-item-content']/following-sibling::div//span[contains(@class,"
                         "'el-dropdown-link')]/preceding-sibling::div//li[@title='删除']".format(HD.fileName))
    # 删除文件夹确定按钮
    del_folder_submit = (By.XPATH, "//div[contains(text(),'您确定要删除此文件夹吗?')]/ancestor::div["
                                   "@class='el-dialog__body']/following-sibling::div//button[text()='确定']")
    # 删除文件确定按钮
    certain_del_btn = (By.XPATH, '//span[text()="{}" and @style]/ancestor::div['
                                 '@class="el-dialog__body"]/following-sibling::div//button[text()="确定"]'.format(
                                    HD.fileName))

    # 移动文件定位树位置
    move_file_locator = (
        By.XPATH, "//div[@class='el-dialog__body']//li[@class='ts-tree-li']//span[contains(text(),'立在地球边上放号')]")

    # 移动文件确定按钮
    move_file_submit = (By.XPATH,
                        "//div[@class='el-dialog__body']//li[@class='ts-tree-li']//span[contains(text(),"
                        "'立在地球边上放号')]/ancestor::div[@class='el-dialog__body']/following-sibling::div//button["
                        "contains(@class,'plain')]")

    # 文件下载按钮
    download_btn = (By.XPATH, "//span[text()='{}']/ancestor::div["
                              "@class='list-item-content']/following-sibling::div//span[contains(text(),"
                              "'下载')]".format(HD.fileName))

    # 新增教材
    exchange_tb = (By.XPATH, '//span[@title="切换教材"]')  # 切换教材按钮
    click_newBtn_tb = (By.CSS_SELECTOR, '.add')  # 添加教材按钮
    school_section_tb = (By.XPATH, "//a[text()='初中']")  # 选择学段
    subject_tb = (By.XPATH, "//a[text()='体育与健康']")  # 选择学科
    version_tb = (By.XPATH, "//a[text()='人教版']")  # 选择版本
    textbook_tb = (By.XPATH, "//a[text()='七年级全一册']")  # 课本
    textbook_tb_submit = (By.XPATH, '//a[text()="七年级全一册"]/ancestor::div['
                                    '@class="el-dialog__body"]/following-sibling::div//button[text()="确定"]')

    # 获取当前教材名称
    textbook_name = (By.CSS_SELECTOR, ".bk-home-aside div.bk-textbook p")  # 当前教材名称

    # 切换到指定教材
    change_tb = (By.XPATH, '//p[@title="人教版体育与健康七年级全一册"]')  # 切换到指定教材
    default_tb = (By.XPATH, '//p[@title="统编版（2019）语文上册"]')  # 默认教材

    # 删除教材
    del_textbook_del_btn = (By.XPATH, '//p[@title="人教版体育与健康七年级全一册"]/preceding-sibling::*[name()="svg"]')
    del_textbook_submit_btn = (By.XPATH, '//div[contains(text(),"您确定删除此教材吗")]/ancestor::div['
                                         '@class="el-dialog__body"]/following-sibling::div//button[text()="确定"]')

    # 备课客户端下载页面
    client_download_page_bk_btn = (By.CSS_SELECTOR, '.its-bk-download .its-bk-header .its-btn')  # 进入备课首页按钮
    client_download_page_desc = (By.CSS_SELECTOR, '.its-desc')  # 中间描述文案 高效编辑，轻松备好课

    # 学科网账号设置页面
    xkw_account = (By.CSS_SELECTOR, '#aLoginName')  # 账号信息

    # 备课帮助页面
    bk_help_page = (By.XPATH, "//span[text()='找资源、找试题']")

    # 备课树
    trees = (By.XPATH, '//span[@class="node-icon open"]/ancestor::p/following-sibling::div[contains(@class,'
                       '"tree-node")]/p/span[@title]')
    active_tree = (By.CSS_SELECTOR, '.node-label.active')

    # 推荐专辑关闭按钮
    feature_close_ico = (By.CSS_SELECTOR, '.bk-tip-btn.el-icon-close')

    # 查看推荐按钮
    view_recommend_ico = (By.CSS_SELECTOR, '.bk-tip-btn.hot')



